import req from "@/http";
/***
 * 示例一
 */
// export interface addArticle_interface {
//   title: string
//   content: string
//   addTime: string
//   tag: string
//   classify: string
//   isPublishState: number
//   articleHeaderImg: string
// }
// export const addArticle = async (data: addArticle_interface) => {
//   const { res, err, isSuccess } = await req({
//     method: "post",
//     url: "/addArticle",
//     data,
//   })
//   return isSuccess ? Promise.resolve(res) : Promise.reject(err)
// }

// export interface getArticle_interface {
//   article_id: number
//   article_title: string
//   article_addTime: string
//   article_readNum: number
//   hasCommentTotal: number
//   article_content: string
//   article_classify: string
//   article_isPublishState: number
//   article_tag: string
//   article_headerImg: string
// }
// /***
//  * 示例二
//  */
// export const getArticle = async (data?: { id?: number }) => {
//   const { res, err, isSuccess } = await req<Array<getArticle_interface>>({
//     method: "get",
//     url: "/getArticle",
//     params: data,
//   })

//   return isSuccess ? Promise.resolve(res) : Promise.reject(err)
// }

//登录
interface Login_args {
  adminUser: string;
  adminPassword: string;
}
//登录
export const Login = async (data: Login_args) => {
  const { res, err, isSuccess } = await req<string>({
    method: "post",
    url: "/AdminLogin",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取组织信息
export const getOrganization = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/admin/info",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};


//获取分类管理列表
export const getCateList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/category/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//新增分类
export const createCate = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/category/save",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//编辑分类
export const updateCate = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/category/update",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//删除分类
export const deleteCate = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/category/delete",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取oss签名
export const getOssApi = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "oss/policy",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取商品管理列表
export const getGoodsList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/order/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//新增商品
export const createGoods = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/order/save",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//编辑商品
export const updateGoods = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/order/update",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//删除商品
export const deleteGoods = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/order/delete",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//编辑商品的标签
export const updateLabel = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/order/tagupdate",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取商品的标签
export const getGoodLabel = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/order/taglist",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//删除商品的标签
export const deleteLabel = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/order/tagdelete",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//设置商品为秒杀商品
export const updateGoodSeckill = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/order/seckillstatus",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取订单管理列表
export const getIndentList = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/indent/list",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//修改订单状态
export const updateIndent = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/indent/update/status",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取用户管理列表
export const getUsersList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/user/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//修改订单状态(拉黑禁用)
export const updateUser = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/user/update/status",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取秒杀管理列表
export const getSeckillList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/seckill/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//修改秒杀价格
export const updateSeckillPrice = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/seckill/priceupdate",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取轮播图列表
export const getSwiperList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/slideshow/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//编辑/新增轮播项
export const updateSwiper = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/slideshow/update",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//删除轮播项
export const deleteSwiper = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/slideshow/delete",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取7天的销售,销售订单量
export const getZation = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/data/zation",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取销售排行榜
export const getRanking = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/data/ranking",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取盈利，销售
export const getDataList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/data/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取进货列表
export const getRestockList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/restock/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//删除进货数据
export const deleteRestock = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/restock/delete",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//新增/编辑进货数据
export const updateRestock = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/restock/update",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//订单获取管理员
export const getAdminList = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/indent/adminlist",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//订单分配管理员
export const deliveryAdmin = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/indent/delivery",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取管理员配送数量
export const getAdminCount = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/data/count",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取优惠卷列表
export const getCouponList = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/rule/list",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//新增优惠卷
export const addCoupon = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/rule/save",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//编辑优惠卷
export const updateCoupon = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/rule/update",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取分类商品
export const getRuleProducts = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/rule/products",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取用户订单排行榜
export const getUserRanking = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/data/userRanking",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//设置配送邮箱开启
export const handleAdminMail = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/data/adminMail",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};
//获取学校组织
export const getOrgSchool = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/organization/school/list",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取有效管理员
export const getSchoolAdmin = async (data: any) => {
  const { res, err, isSuccess } = await req({
    method: "post",
    url: "/organization/school/data/list",
    data,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};

//获取当前登录账号信息
export const getAdminName = async (params: any) => {
  const { res, err, isSuccess } = await req({
    method: "get",
    url: "/admin/name",
    params,
  });

  return isSuccess ? Promise.resolve(res) : Promise.reject(err);
};
